#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdbool.h>
#include<stdlib.h>
struct TreeNode {
    int val;
    struct TreeNode* left;
    struct TreeNode* right;

};

bool issametree(struct TreeNode* root1, struct TreeNode* root2) {
    if (root1 == NULL && root2 == NULL) {
        return true;
    }
    if (root1 == NULL || root2 == NULL) {
        return false;
    }
    if (root1->val != root2->val) {
        return false;
    }
    return issametree(root1->left, root2->left) && issametree(root1->right, root2->right);
}



bool isSubtree(struct TreeNode* root, struct TreeNode* subRoot) {
    if (root == NULL) {
        return false;
    }
    if (root->val == subRoot->val) {
        if (issametree(root, subRoot))
            return true;
    }
    return isSubtree(root->left, subRoot) || isSubtree(root->right, subRoot);
}
int treesize(struct TreeNode* root) {
    if (root == NULL) {
        return 0;
    }
    return treesize(root->left) + treesize(root->right) + 1;
}
void preorder(struct TreeNode* root, int* a, int* pi) {
    if (root == NULL) {
        return;
    }

    preorder(root->left, a, pi);

    preorder(root->right, a, pi);
    a[*pi] = root->val;
    (*pi)++;
}

int* postorderTraversal(struct TreeNode* root, int* returnSize) {
    int n = treesize(root);
    int* a = (int*)malloc(sizeof(int) * n);
    int m = 0;
    preorder(root, a, &m);

    *returnSize = n;
    return a;
}
bool issame(struct TreeNode* left, struct TreeNode* right) {
    if (left == NULL && right == NULL) {
        return true;
    }
    if (left == NULL || right == NULL) {
        return false;
    }
    if (left->val != right->val) {
        return false;
    }
    return issame(left->left, right->right) && issame(right->left, left->right);
}

bool isSymmetric(struct TreeNode* root) {
    if (root->left == NULL && root->right == NULL) {
        return true;
    }
    if (root->left == NULL || root->right == NULL) {
        return false;
    }
    if (root->left->val != root->right->val) {
        return false;
    }
    return issame(root->left, root->right);
}
bool isonenum(struct TreeNode* root, int num) {
    if (root == NULL) {
        return true;
    }
    if (root->left != NULL && root->left->val != num || root->right != NULL && root->right->val != num) {
        return false;
    }
    return isonenum(root->left, num) && isonenum(root->right, num);
}
bool isUnivalTree(struct TreeNode* root) {
    return isonenum(root, root->val);
}
struct TreeNode* invertTree(struct TreeNode* root) {
    if (root == NULL) {
        return NULL;
    }
    struct TreeNode* left = invertTree(root->left);
    struct TreeNode* right = invertTree(root->right);
    root->left = right;
    root->right = left;



    return root;
}
int main() {

    return 0;
}